import pygame
from pygame.locals import *
from pygame.sprite import Sprite

class Robot(Sprite):
    def __init__(self):
		pygame.mixer.init()
		self.image = pygame.image.load("nave1.png").convert_alpha()
		self.rect = self.image.get_rect()
		self.move_sound = pygame.mixer.Sound("robot_move.wav")
		self.move_sound.set_volume(0.75)
		
    def playMoveSound(self):
		self.move_sound.play()
	
    def stopMoveSound(self):
		self.move_sound.stop()

    def update(self):
		teclas = pygame.key.get_pressed()	
		if teclas[K_LEFT]:
			self.playMoveSound()
			if self.rect.x > 0:
				self.rect.x -= 5
		if teclas[K_RIGHT]:
			self.playMoveSound()
			if self.rect.x < 593:
				self.rect.x += 5
		if teclas[K_UP]:
			self.playMoveSound()
			if self.rect.y > 0:
				self.rect.y -= 5
		if teclas[K_DOWN]:
			self.playMoveSound()
			if self.rect.y < 433:
				self.rect.y += 5
